from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired, Length


# ...
class LoginForm(FlaskForm):
    """登录表单类"""
    username = StringField(label='用户名',
                           validators=[DataRequired()],
                           render_kw={
                               'placeholder': '用户名',
                               'class': 'input_text easyui-textbox',
                               'data-options': "iconCls:'icon-man',iconWidth:30,iconAlign:'left'",
                               'style': "width:100%;height:35px;"
                           })
    password = PasswordField(label='密码',
                             validators=[DataRequired(),
                                         Length(3, 8, '密码长度必须在3-8之间')],
                             render_kw={
                                 'placeholder': '密码',
                                 'class': "easyui-passwordbox",
                                 'data-options': "iconWidth:30,iconAlign:'left'",
                                 'style': "width:100%;height:35px;"
                             })

    submit = SubmitField(label='登录',
                             render_kw={
                                 'placeholder': '登录',
                                 'class': "easyui-linkbutton",
                                 'style': "width:100%;height:35px;"
                             })
